package Day4;

import java.util.*;
// 1:无需package
// 2: 类名必须Main, 不可修改
/**
 * 2020JavaB真题: 寻找2020
 * https://www.lanqiao.cn/problems/1065/learning/
 */
public class Main2 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        String[] s = new String[310];
        for(int i = 1; i <= 300; i++){
          s[i] = scan.next();
        }

        int count = 0;

        for(int i = 1; i < s.length; i++){
          for(int j = 0; j < s[i].length(); j++){
            if(s[i].charAt(j) == '2'){
              if(j + 3 < s[i].length() && s[i].charAt(j + 1) == '0' && s[i].charAt(j + 2) == '2' && s[i].charAt(j + 3) == '0'){
                count++;
              }
              if(i + 3 < s.length && s[i + 1].charAt(j) == '0' && s[i + 2].charAt(j) == '2' && s[i + 3].charAt(j) == '0'){
                count++;
              }
              if(j + 3 < s[i].length() && s[i + 1].charAt(j + 1) == '0' && s[i + 2].charAt(j + 2) == '2' && s[i + 3].charAt(j + 3) == '0'){
                count++;
              }
            }
          }
        }
        System.out.println(count);
        scan.close();
    }
}